package com.mf.daoImpl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.mf.dao.MusicDao;
import com.mf.entity.Music;
import com.mf.util.JdbcDaoHelper;

public class MusicDaoImpl extends BaseDaoImpl<Music> implements MusicDao{

	
    private String sql;

    private PreparedStatement statement;

    private ResultSet rs;
	
	@Override
	public List<Music> getAllMusic() {
		
		List<Music> list=new ArrayList<Music>();
		sql="SELECT * FROM realmf.music";
		try {
			
			statement=JdbcDaoHelper.getPreparedStatement(sql);
			rs=statement.executeQuery();
			while(rs.next()){
				Music music=new Music();
				music.setId(rs.getInt("id"));
				music.setMusicname(rs.getString("musicname"));
				music.setPictitle(rs.getString("pictitle"));
				music.setRealname(rs.getString("realname"));
				list.add(music);
			}
			
			return list;
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			JdbcDaoHelper.release(statement, rs);
		}
		return null;
		
	}

}
